package org.jeecg.modules.user.code.controller;

import com.sun.istack.logging.Logger;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.modules.user.code.entity.SmsCode;
import org.jeecg.modules.user.code.service.SmsCodeService;
//import org.jeecg.modules.online.config.exception.BusinessException;
import org.jeecg.modules.utils.BikeResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 南京深卡网络技术有限公司
 */
@Validated
@RestController
@RequestMapping("/sendCode")
@Api(tags = "发送短信")
public class SmsCodeController  {
    private static final Logger LOG = Logger.getLogger(SmsCodeController.class);
    @Autowired
    private SmsCodeService smsCodeService;

    @ApiOperation(value = "发送短信验证码", notes = "发送短信验证码")
    @RequestMapping(value = "/sendSmsCode", method = RequestMethod.GET)
    public BikeResult sendSmsCode(@RequestParam("phone") String phone, @RequestParam("type") int type, HttpServletRequest request){
        return smsCodeService.sendSmsCode(phone, type);
    }

    @ApiOperation(value = "校验短信验证码", notes = "校验短信验证码")
    @RequestMapping(value = "/checkSmsCode", method = RequestMethod.POST)
    public BikeResult checkSmsCode(@RequestBody SmsCode smsCode, HttpServletRequest request)  {
        return smsCodeService.checkSmsCode(smsCode);
    }
}
